<script setup lang="ts">
import weblogo from "~/assets/web-logo.png";
import weblogo1 from "~/assets/web-logo-1.png";
import { ArrowRight } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";
import { useUserStore } from "~/store/useUser";
import { useRouter, useRoute } from "vue-router";
import { computed, ref, onMounted, watch, onUnmounted } from "vue";
import { useSocketStore } from "~/store/useSocket";
import { searchRecord, getConcernAccountList } from "~/api/user";

const emits = defineEmits(["headerSearch"]);
const user = useUserStore();
const route = useRoute();
const router = useRouter();
const socketStore = useSocketStore();
const currentRoute = computed(() => {
  return route.path;
});
const noReadMsgNum = computed(() => socketStore.noReadMsgNum);

const defaultProps = defineProps({
  bgColor: {
    type: String,
    default: "none",
  },
  showSearch: {
    type: Boolean,
    default: true,
  },
  borderBottom: {
    type: Boolean,
    default: true,
  },
});

const color = computed(function () {
  if (whiteHeaderMenu.value) {
    return "rgba(25, 30, 40, 0.60)";
  }
  if (!defaultProps.bgColor) {
    return "rgba(255, 255, 255, 0.48)";
  }
  if (defaultProps.bgColor === "transparent") {
    return "rgba(255, 255, 255, 0.48)";
  }
  if (defaultProps.bgColor == "white") {
    return "rgba(25, 30, 40, 0.60)";
  }
  return "rgba(25, 30, 40, 0.60)";
});

const activeColor = computed(function () {
  if (whiteHeaderMenu.value || defaultProps.bgColor === "white") {
    return "#1DBF73";
  }
  return "#fff";
});

const btnColor = computed(function () {
  if (whiteHeaderMenu.value || defaultProps.bgColor === "white") {
    return "#191E2884";
  }
  return "#fff";
});

const activebgColor = computed(function () {
  if (whiteHeaderMenu.value) {
    return "#FFFFFF";
  }
  return defaultProps.bgColor;
});
const menuLineBlock = computed(function () {
  if (defaultProps.bgColor === "white") {
    return "block";
  }
  return "none";
});

const userMneuSHow = ref(false);
const userHover = () => {
  userMneuSHow.value = true;
};
const userLeave = () => {
  setTimeout(() => {
    userMneuSHow.value = false;
  }, 500);
};

const whiteHeaderMenu = ref(false);
const pageScroll = () => {
  let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  //console.log(scrollTop);
  if (scrollTop >= 200) {
    whiteHeaderMenu.value = true;
  } else {
    whiteHeaderMenu.value = false;
  }
};

const isLogin = ref(false);
const userInfo = ref({});
const userInitialized = ref(false);
const hasShop = ref(false);
const hasCompany = ref(false);

// 在组件创建时就初始化用户信息
isLogin.value = user.isLogin;
userInfo.value = { ...user.getUserInfo };
hasShop.value = user.getHasShop;
hasCompany.value = user.getHasCompany;
userInitialized.value = true;

console.log('HeaderMenuWhite created - isLogin:', isLogin.value);
console.log('HeaderMenuWhite created - userInfo:', userInfo.value);

onMounted(async () => {
  console.log('HeaderMenuWhite mounted - isLogin:', isLogin.value);
  console.log('HeaderMenuWhite mounted - userInfo:', userInfo.value);
  console.log('mounted时companyId值:', userInfo.value.companyId);
  console.log('mounted时addCompany值:', userInfo.value.addCompany);

  // 如果已登录，尝试获取最新的用户信息
  if (isLogin.value && (!userInfo.value || Object.keys(userInfo.value).length === 0)) {
    try {
      await user.userInfoAction();
      userInfo.value = { ...user.getUserInfo };
      console.log('HeaderMenuWhite updated userInfo:', userInfo.value);
      console.log('更新后companyId值:', userInfo.value.companyId);
      console.log('更新后addCompany值:', userInfo.value.addCompany);
    } catch (error) {
      console.error('获取用户信息失败:', error);
    }
  }

  document.addEventListener("scroll", pageScroll);
  //
  const keywordText = route.query.keyword;
  const source = route.query.source;
  if (keywordText && source !== "homeInput") {
    keyword.value = decodeURIComponent(keywordText as string) || "";
  }
  // 点击页面其他地方，隐藏搜索结果
  document.addEventListener("click", () => {
    searchResList.value = [];
  });
});

// 更改监听用户信息变化的方式
watch(
  () => user.getUserInfo,
  (newValue, oldValue) => {
    // 确保即使对象引用相同也能触发更新
    userInfo.value = { ...newValue };
    userInitialized.value = true;
    console.log('用户信息已更新', userInfo.value);
    console.log('companyId值:', userInfo.value.companyId);
    console.log('addCompany值:', userInfo.value.addCompany);
    console.log('用户信息所有字段:', Object.keys(userInfo.value));
  },
  { deep: true } // 深度监听
);

// 监听登录状态变化
watch(
  () => user.isLogin,
  (newValue, oldValue) => {
    isLogin.value = newValue;
    userInitialized.value = true;
    // 登录状态变化时更新用户信息
    if (newValue) {
      userInfo.value = { ...user.getUserInfo };
      hasShop.value = user.getHasShop;
      hasCompany.value = user.getHasCompany;
      console.log('登录状态变为已登录，更新用户信息:', userInfo.value);
      console.log('登录后companyId值:', userInfo.value.companyId);
      console.log('登录后addCompany值:', userInfo.value.addCompany);
      console.log('登录后hasShop值:', hasShop.value);
    } else {
      userInfo.value = {};
      hasShop.value = false;
      hasCompany.value = false;
      console.log('登录状态变为未登录，清空用户信息');
    }
  },
  { immediate: true }
);

// 监听 hasShop 状态变化
watch(
  () => user.getHasShop,
  (newValue) => {
    hasShop.value = newValue;
    console.log('hasShop状态已更新:', hasShop.value);
  },
  { immediate: true }
);

watch(
  () => user.getHasCompany,
  (newValue) => {
    hasCompany.value = newValue;
  },
  { immediate: true }
);

onUnmounted(() => {
  document.removeEventListener("scroll", pageScroll);
});
//
const exitSys = async () => {
  try {
    await user.logout();
    // 手动更新状态，确保界面即时更新
    isLogin.value = false;
    userInfo.value = {};
    router.push({ path: "/login" });
  } catch (error) {
    console.error('退出登录失败:', error);
    // 即使退出失败，也清理本地状态
    isLogin.value = false;
    userInfo.value = {};
    router.push({ path: "/login" });
  }
};

const toLogin = () => {
  router.push({ path: "/login" });
};

//
const keyword = ref("");
watch(keyword, (newValue) => {
  if (!newValue) {
    console.log(11111111111111111);
    searchResList.value = [];
  }
});

const search = () => {
  if (!keyword.value) {
    return;
  }
  searchResList.value = [];
  router.push({
    path: "/commodity",
    query: { keyword: encodeURIComponent(keyword.value) },
  });
  emits("headerSearch", keyword.value);
};
//
const searchResList = ref([]);

const timer = ref();
const getSearchRecord = async (wordText: string) => {
  if (!wordText) {
    searchResList.value = [];
    return;
  }
  // 去除所有空格后判断
  if (wordText.replace(/\s/g, "").length === 0) {
    keyword.value = "";
    return;
  }
  // 限制长度不能超过20个字符，如果超过，则截取前20个字符
  if (wordText.length > 20) {
    keyword.value = wordText.slice(0, 20);
  }
  // 节流
  if (timer.value) {
    clearTimeout(timer.value);
  }
  timer.value = setTimeout(async () => {
    const data = await searchRecord({ keyword: wordText, type: 2 });
    searchResList.value = data.data.slice(0, 10);
  }, 1000);
};
//
const toSellerCenter = () => {
  // 检查用户是否已登录
  if (!user.isLogin) {
    ElMessage.warning('请先登录后再进入卖家中心');
    router.push('/login');
    return;
  }

  const config = useRuntimeConfig();
  const sellerCenterUrl = config.public.sellerCenterUrl;
  if (sellerCenterUrl) {
    window.open(sellerCenterUrl, '_blank');
  }
};
</script>

<template>
  <div class="menu-box" :style="{
    background: activebgColor,
    boxShadow:
      defaultProps.borderBottom || whiteHeaderMenu
        ? 'inset 0px -1px 0px 0px rgba(0,0,0,0.06)'
        : 'none',
  }">
    <div class="header-menu">
      <h1 class="logo" title="技能猴子">
        <nuxt-link to="/"><img :src="whiteHeaderMenu || defaultProps.bgColor === 'white' ? weblogo1 : weblogo
          " alt="技能猴子" /></nuxt-link>
      </h1>
      <div class="search" v-if="showSearch">
        <input v-model="keyword" type="text" placeholder="搜索任何服务..." @input="getSearchRecord(keyword)" />
        <button @click="search">
          <img src="~/assets/search-icon.png" alt="" />
        </button>
        <div class="search-res-list" v-if="searchResList.length">
          <p v-for="item of searchResList" :key="item.id">
            <nuxt-link :to="`/commodity?keyword=${item.keyword}`">{{
              item.keyword
              }}</nuxt-link>
          </p>
        </div>
      </div>
      <div class="menus">
        <div class="menu-list">
          <nuxt-link to="/" :class="{ active: currentRoute === '/' }"
            :style="currentRoute === '/' ? 'color: activeColor' : ''">首页</nuxt-link>
          <nuxt-link to="/commodity" :class="{ active: currentRoute === '/commodity' }"
            :style="currentRoute === '/commodity' ? 'color: activeColor' : ''">商品</nuxt-link>
          <!-- <nuxt-link>猴子素材</nuxt-link>
          <nuxt-link>企业雇佣</nuxt-link>
          <nuxt-link>效率工具</nuxt-link> -->
          <nuxt-link v-if="!hasShop" to="/sellerRegistration"
            :class="{ active: currentRoute === '/sellerRegistration' }"
            :style="currentRoute === '/sellerRegistration' ? 'color: activeColor' : ''">卖家入驻</nuxt-link>
          <nuxt-link v-if="hasShop && isLogin" to="/myShop" :class="{ active: currentRoute === '/myShop' }"
            :style="currentRoute === '/myShop' ? 'color: activeColor' : ''">店铺信息</nuxt-link>
          <nuxt-link v-if="isLogin" to="/shoppingCart" :class="{ active: currentRoute === '/shoppingCart' }"
            :style="currentRoute === '/shoppingCart' ? 'color: activeColor' : ''">购物车</nuxt-link>
          <nuxt-link v-if="isLogin" to="/myOrder" :class="{ active: currentRoute === '/myOrder' }"
            :style="currentRoute === '/myOrder' ? 'color: activeColor' : ''">订单</nuxt-link>
          <!-- <nuxt-link
            v-if="isLogin"
            to="/chat"
            :class="{ active: currentRoute === '/chat' }"
            :style="currentRoute === '/chat' ? 'color: activeColor' : ''"
            >消息
            <span v-if="noReadMsgNum && noReadMsgNum > 0" class="msg-num">{{
              noReadMsgNum
            }}</span></nuxt-link
          > -->
          <nuxt-link to="/news" :class="{ active: currentRoute === '/news' }"
            :style="currentRoute === '/news' ? 'color: activeColor' : ''">技能头条</nuxt-link>
          <nuxt-link to="/appDownload" :class="{ active: currentRoute === '/appDownload' }"
            :style="currentRoute === '/appDownload' ? 'color: activeColor' : ''">下载APP</nuxt-link>
        </div>
        <div class="btns" v-if="!isLogin">
          <button @click="toSellerCenter" class="seller-central"
            :style="{ color: btnColor, border: `1px solid ${btnColor}` }">
            卖家后台
          </button>
          <button class="login-reg" @click="toLogin">登录/注册</button>
        </div>
      </div>
      <div class="user" v-if="isLogin && userInitialized">
        <!-- 显示手机号和退出按钮 -->
        <div class="user-info">
          <span class="phone-number" :style="{ color }">{{ userInfo.username || userInfo.phone || userInfo.nickname ||
            '用户' }}</span>
          <!-- <button class="logout-btn" @click="exitSys">退出</button> -->
        </div>

        <!-- 保留原有的用户头像和下拉菜单 -->
        <div class="user-avatar">
          <img v-if="userInfo.avatar" :src="userInfo.avatar" alt="" />
          <img v-else src="~/assets/app-mj.png" alt="" />
          <!--菜单-->
          <div class="user-menu-box">
            <div class="menus">
              <NuxtLink to="/myHomePage"><b>我的主页</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <NuxtLink v-if="hasShop" to="/myShop"><b>店铺信息</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <NuxtLink v-if="hasCompany" to="/companyHome"><b>公司主页</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <NuxtLink v-else to="/enterpriseJoin"><b>加入企业</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <!--              <NuxtLink to="/myBill"-->
              <!--                ><b>我的账单</b> <el-icon><ArrowRight /></el-icon-->
              <!--              ></NuxtLink>-->
              <NuxtLink to="/invoice"><b>开票</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <NuxtLink v-if="hasCompany" to="/companyAccount"><b>企业账户</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <NuxtLink to="/myAttention"><b>我的关注</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <NuxtLink to="/bindingNotification"><b>绑定微信通知</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <NuxtLink to="/setUp"><b>设置</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
              <button @click="toSellerCenter" class="menu-button"><b>进入卖家中心</b> <el-icon>
                  <ArrowRight />
                </el-icon></button>
              <NuxtLink @click="exitSys"><b>退出登录</b> <el-icon>
                  <ArrowRight />
                </el-icon></NuxtLink>
            </div>
          </div>
        </div>
      </div>
      <!-- 加载状态 -->
      <div class="user-loading" v-else-if="isLogin && !userInitialized">
        <div class="loading-placeholder">加载中...</div>
      </div>
    </div>
    <MsgAudio />
  </div>
</template>

<style scoped lang="scss">
.menu-box {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 80px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  transition: all 0.1s ease-in-out;
  padding: 0 20px;
  box-sizing: border-box;

  @media (max-width: 768px) {
    height: 60px;
    padding: 0 16px;
  }

  @media (max-width: 480px) {
    height: 56px;
    padding: 0 12px;
  }
}

.user {
  position: relative;
  padding-left: 20px;
  display: flex;
  align-items: center;
  gap: 12px;

  @media (max-width: 768px) {
    padding-left: 12px;
    gap: 8px;
  }

  @media (max-width: 480px) {
    padding-left: 8px;
    gap: 6px;
  }

  .user-info {
    display: flex;
    align-items: center;
    gap: 12px;

    @media (max-width: 768px) {
      gap: 8px;
    }

    @media (max-width: 480px) {
      gap: 6px;
    }

    .phone-number {
      color: #191e28;
      font-size: 14px;
      font-weight: 500;
      white-space: nowrap;

      @media (max-width: 480px) {
        font-size: 12px;
      }
    }

    .logout-btn {
      background: #f56c6c;
      color: #fff;
      border: none;
      border-radius: 6px;
      padding: 6px 12px;
      font-size: 12px;
      cursor: pointer;
      white-space: nowrap;
      transition: all 0.2s;

      @media (max-width: 480px) {
        padding: 4px 8px;
        font-size: 11px;
        border-radius: 4px;
      }

      &:hover {
        background: #f45a5a;
        transform: translateY(-1px);
      }

      &:active {
        transform: translateY(0);
      }
    }
  }

  .user-avatar {
    position: relative;

    &:hover {
      .user-menu-box {
        display: block;
      }
    }

    img {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      cursor: pointer;

      @media (max-width: 480px) {
        width: 32px;
        height: 32px;
      }
    }
  }

  .user-menu-box {
    display: none;
    width: 152px;
    position: absolute;
    right: 0;

    @media (max-width: 480px) {
      width: 140px;
      right: -10px;
    }
  }

  .menus {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    width: 152px;
    box-shadow: 0px 0px 16px 0px rgba(11, 13, 18, 0.06);
    border-radius: 6px;
    border: 1px solid rgba(25, 30, 40, 0.08);
    padding: 2px 0;
    box-sizing: border-box;
    margin-top: 24px;
    transition: all 0.1s;

    @media (max-width: 480px) {
      width: 140px;
      margin-top: 16px;
    }

    a,
    .menu-button {
      width: 100%;
      height: 44px;
      line-height: 44px;
      display: flex;
      align-items: center;
      text-decoration: none;
      color: #191e28;
      padding: 0 20px;
      box-sizing: border-box;
      cursor: pointer;
      font-size: 14px;
      background: none;
      border: none;
      text-align: left;

      @media (max-width: 480px) {
        height: 40px;
        line-height: 40px;
        padding: 0 16px;
        font-size: 13px;
      }

      &:hover {
        background: rgba(25, 30, 40, 0.02);
        color: #1dbf73;
      }

      b {
        flex: 1;
      }
    }
  }
}

.user-loading {
  padding-left: 20px;

  @media (max-width: 768px) {
    padding-left: 12px;
  }

  @media (max-width: 480px) {
    padding-left: 8px;
  }

  .loading-placeholder {
    color: #191e28;
    font-size: 14px;
    font-weight: 500;

    @media (max-width: 480px) {
      font-size: 12px;
    }
  }
}

.header-menu {
  width: 100%;
  max-width: 1200px;
  height: 80px;
  display: flex;
  align-items: center;

  @media (max-width: 768px) {
    height: 60px;
  }

  @media (max-width: 480px) {
    height: 56px;
  }
}

.logo {
  margin-right: 20px;
  height: 40px;
  flex-shrink: 0;

  @media (max-width: 768px) {
    margin-right: 12px;
    height: 32px;
  }

  @media (max-width: 480px) {
    margin-right: 8px;
    height: 28px;
  }

  a {
    height: 40px;

    @media (max-width: 768px) {
      height: 32px;
    }

    @media (max-width: 480px) {
      height: 28px;
    }
  }

  img {
    width: 118px;
    height: 40px;

    @media (max-width: 768px) {
      width: 94px;
      height: 32px;
    }

    @media (max-width: 480px) {
      width: 82px;
      height: 28px;
    }
  }
}

.search {
  display: flex;
  align-items: center;
  height: 42px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid rgba(25, 30, 40, 0.08);
  position: relative;
  margin-right: 20px;
  min-width: 200px;
  overflow: hidden;

  @media (max-width: 1024px) {
    min-width: 160px;
    margin-right: 12px;
  }

  @media (max-width: 768px) {
    min-width: 120px;
    height: 36px;
    margin-right: 8px;
  }

  @media (max-width: 480px) {
    min-width: 100px;
    height: 32px;
    margin-right: 6px;
  }

  @media (max-width: 360px) {
    min-width: 90px;
    height: 30px;
  }

  input {
    border: none;
    padding: 0 12px;
    outline: none;
    user-select: none;
    height: 100%;
    border-radius: 8px;
    flex: 1;
    font-size: 14px;
    min-width: 0;
    width: 100%;

    @media (max-width: 768px) {
      padding: 0 8px;
      font-size: 13px;
    }

    @media (max-width: 480px) {
      padding: 0 6px;
      font-size: 12px;
    }

    @media (max-width: 360px) {
      padding: 0 4px;
      font-size: 11px;
    }
  }

  button {
    background: #1dbf73;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    margin-right: 4px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;

    @media (max-width: 768px) {
      width: 28px;
      height: 28px;
      margin-right: 3px;
    }

    @media (max-width: 480px) {
      width: 24px;
      height: 24px;
      margin-right: 2px;
    }

    &:hover {
      background: #019a81;

      img {
        transform: scale(1.2);
      }
    }

    img {
      width: 16px;
      height: 16px;
      margin: 0;

      @media (max-width: 768px) {
        width: 14px;
        height: 14px;
      }

      @media (max-width: 480px) {
        width: 12px;
        height: 12px;
      }
    }
  }

  .search-res-list {
    position: absolute;
    top: 48px;
    left: 0;
    z-index: 9;
    background: #fff;
    box-shadow: 0px 0px 20px 0px rgba(11, 13, 18, 0.06);
    border-radius: 8px;
    border: 1px solid rgba(25, 30, 40, 0.12);
    width: 226px;
    padding: 12px;
    box-sizing: border-box;

    @media (max-width: 768px) {
      top: 42px;
      width: 200px;
      padding: 8px;
    }

    @media (max-width: 480px) {
      top: 38px;
      width: 180px;
      padding: 6px;
    }

    p {
      padding: 8px 12px;
      background: #fff;
      border-radius: 8px;
      font-size: 14px;
      color: #191e28;

      @media (max-width: 480px) {
        padding: 6px 8px;
        font-size: 13px;
      }

      &:hover {
        background: rgba(25, 30, 40, 0.02);
      }

      a {
        display: block;
        font-size: 14px;
        color: #191e28;
        font-style: normal;
        text-decoration: none;

        @media (max-width: 480px) {
          font-size: 13px;
        }
      }
    }
  }
}

.menus {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;

  .menu-list {
    color: rgba(25, 30, 40, 0.6);

    @media (max-width: 768px) {
      display: none;
    }

    @media (min-width: 769px) and (max-width: 1024px) {
      a {
        padding: 0 8px;
        font-size: 14px;
      }
    }

    a {
      padding: 0 15px;
      display: inline-block;
      line-height: 80px;
      cursor: pointer;
      text-decoration: none;
      color: v-bind(color);
      position: relative;
      white-space: nowrap;

      @media (max-width: 768px) {
        line-height: 60px;
      }

      @media (max-width: 480px) {
        line-height: 56px;
      }

      .msg-num {
        display: inline-block;
        width: 15px;
        height: 15px;
        line-height: 15px;
        background: rgb(255, 79, 79);
        border-radius: 50%;
        color: #fff;
        position: absolute;
        font-size: 8px;
        top: 28px;
        right: 3px;
        text-align: center;

        @media (max-width: 768px) {
          top: 22px;
          width: 12px;
          height: 12px;
          line-height: 12px;
          font-size: 7px;
        }

        @media (max-width: 480px) {
          top: 20px;
          width: 10px;
          height: 10px;
          line-height: 10px;
          font-size: 6px;
        }
      }

      &.active {
        color: v-bind(activeColor);
        position: relative;

        &:before {
          content: "";
          display: v-bind(menuLineBlock);
          width: 28px;
          position: absolute;
          bottom: 0;
          left: 50%;
          margin-left: -14px;
          border-bottom: 2px solid #1dbf73;
        }
      }

      &:hover {
        color: #1dbf73;
      }
    }
  }

  .btns {
    display: flex;
    align-items: center;
    gap: 15px;

    @media (max-width: 480px) {
      gap: 8px;
    }

    button {
      font-size: 12px;
      cursor: pointer;
      white-space: nowrap;

      @media (max-width: 480px) {
        font-size: 11px;
      }
    }

    .seller-central {
      display: inline-block;
      background: none;
      border-radius: 8px;
      width: 86px;
      height: 42px;
      border: 1px solid #fff;
      color: #fff;
      text-decoration: none;
      line-height: 42px;
      text-align: center;
      box-sizing: border-box;

      @media (max-width: 768px) {
        width: 70px;
        height: 36px;
        line-height: 36px;
        font-size: 11px;
        border-radius: 6px;
      }

      @media (max-width: 480px) {
        width: 58px;
        height: 32px;
        line-height: 32px;
        font-size: 10px;
        border-radius: 6px;
      }

      @media (max-width: 360px) {
        width: 52px;
        height: 30px;
        line-height: 30px;
        font-size: 9px;
        border-radius: 6px;
      }
    }

    .login-reg {
      background: #1dbf73;
      border-radius: 8px;
      width: 86px;
      height: 42px;
      border: 1px solid #1dbf73;
      color: #fff;

      @media (max-width: 768px) {
        width: 70px;
        height: 36px;
        line-height: 36px;
        font-size: 11px;
        border-radius: 6px;
      }

      @media (max-width: 480px) {
        width: 58px;
        height: 32px;
        line-height: 32px;
        font-size: 10px;
        border-radius: 6px;
      }

      @media (max-width: 360px) {
        width: 52px;
        height: 30px;
        line-height: 30px;
        font-size: 9px;
        border-radius: 6px;
      }
    }
  }
}

// 平板适配
@media (min-width: 769px) and (max-width: 1024px) {
  .header-menu {
    max-width: 100%;
  }
}

// 大屏幕适配
@media (min-width: 1200px) {
  .header-menu {
    max-width: 1400px;
  }
}
</style>
